//TODO 今日推荐
//index.js
//获取应用实例
const app = getApp()
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
var amapFile = require('../../utils/amap-wx.js');
var util = require('../../utils/util.js');
var wxParse = require('../../../wxParse/wxParse.js')
Page({
  data: {
    date: '',
    pd:'',
    // 高度
    index: 0,
    pageBackgroundColor: '#5cb85c',
    time: '12:00',
    height: "0", 
    height002: "0",
    isyuyue: false,
    yuyue: '',
    height01: '0',
    message:'恭喜您已经成功预定了4月8日14:00的大厅5号桌',
    hide : true,
    hidescanningOK:true,
    // 自带弹框
    // text:"这是一个页面"
    hiddenModal: true,
    jcrsarray: ['1人', '2人', '3人', '4人', '5人', '6人', '7人', '8人', '9人', '10人', '10人以上',],
    jindex:0,
    ling: "/images/quan.png",
    zheng: "/images/quan1.png", 
    ban: "/images/ban.png",
    array: [],
    coupons:{},
    iconimg: [
      { 'image': '/images/outshop.png', 'name': '外卖', 'bind': 'takeOutFood' }, 
      { 'image': '/images/yuding.png', 'name': '预定', 'bind': 'popwinyuding' }, 
      { 'image': '/images/dengdai.png', 'name': '排队', 'url': '', 'bind': 'scanning' }, 
      { 'image': '/images/caidan.png', 'name': '点餐', 'url': '', 'bind':'breakout'}
      ],
    todayimg:"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1522643382062&di=df4d0043e61eb23a1dfc3adad5fd6b9d&imgtype=0&src=http%3A%2F%2Fwww.taopic.com%2Fuploads%2Fallimg%2F140826%2F240375-140R60JP775.jpg",
    indicatorDots: false,
    autoplay: true, //自动切换
    circular: true, //衔接滑动  无缝轮播
    interval: 5000,
    duration: 1000,
    showView: false,
    showViewpop: true,
    received: "",
    unreceive: ""
  },
  phone:function(e){
      console.log(e);
      var phone = e.currentTarget.dataset.phone;
      wx.makePhoneCall({
        phoneNumber: phone
      })
  },
  maps:function(e){
    // ——————————————点击跳转地图页面——————————
      var that = this
      wx.openLocation({
        latitude: that.data.sjdzlat,
        longitude: that.data.sjdzlng,
        name: that.data.store.name,
        address: that.data.store.address
      })
  },
  yl:function(e){
    console.log(e);
    var imgarr = e.currentTarget.dataset.srdata;
    var imgsrc = e.currentTarget.dataset.src;

    var newarr = [];
    for(var i = 0; i < imgarr.length;i++){
        newarr.push(this.data.url+imgarr[i]);
    }
    wx.previewImage({
      current: imgsrc, // 当前显示图片的http链接 
      urls: newarr // 需要预览的图片http链接列表 
    })
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  bindPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      index: e.detail.value
    })
  },
  lqyhj:function(e){
    // console.log(e);
    var user_id = wx.getStorageSync('users').id
    let coupons_id = this.data.coupons[0].id
    // console.log(coupons_id)
    var that = this
    app.util.request({
      'url': 'entry/wxapp/AddCoupons',
      'cachetime': '0',
      data: { user_id: user_id, coupons_id: coupons_id },
      success: function (res) {
        if (res.data == 1) {
          wx.showToast({
            title: '领取成功',
            icon: 'success',
            duration: 1000
          })
          that.onChangeShowState();
          let unreceive = that.data.unreceive;
          let received = that.data.received;
          received.push(unreceive[index]);
          unreceive.splice(index, 1);
          setTimeout(function () {
            that.setData({
              received: received,
              unreceive: unreceive
            });
          }, 1000)
        }else{
          wx.showToast({
            title: '已领取',
            icon: 'success',
            duration: 1000
          })
        }
      },
    })
  },
  breakout: function (e) {
    // var path = "zh_dianc/pages/index/index?scene=5"
    // console.log(path.substring(15))
    // var tnurl = '../' + path.substring(15)
    // console.log(tnurl)
    // wx.navigateTo({
    //   url: tnurl
    // })
    wx.scanCode({
      success: (res) => {
        console.log(res)
        var path = res.path

        var tnurl = '../' + path.substring(15)
        wx.navigateTo({
          url: tnurl,
        })
      },
      fail: (res) => {
        console.log('扫码fail')
        // wx.showToast({
        //   title: '二维码错误',
        //   image:'../images/x.png'
        // })
      }
    })
  },
  onLoad: function (options) {
    var that = this;
    var end = util.formatTime(new Date).substring(0, 10).replace(/\//g, "-");
    console.log(end.toString())
    this.setData({
      date: end
    })
    console.log(options)
    var scene = decodeURIComponent(options.scene)
    console.log('scene', scene)
    if (scene != 'undefined') {
      var fxzuid = scene
    }
    if (options.userid != null) {
      console.log('转发获取到的userid:', options.userid)
      var fxzuid = options.userid
    }
    console.log('fxzuid', fxzuid)
    // console.log('用户id' + wx.getStorageSync('users').id);

    console.log('商家id' + that.data.mdxx);
    //当前时间
    var time = util.formatTime(new Date());
    var current_time = time.slice(11, 16)
    console.log(current_time)
    this.setData({
      current_time: current_time
    })
    //
    var that = this;
    //tq
    var myAmapFun = new amapFile.AMapWX({ key: 'd03d1ecd781de95397abc7c9f60273e2' });
    myAmapFun.getWeather({
      success: function (data) {
        //成功回调
        console.log(data)
        that.setData({
          tianqi: data
        })
      },
      fail: function (info) {
        //失败回调
        console.log(info)
      }
    })
    //获取设备高度
    wx.getSystemInfo({
      success(res) {
        that.setData({
          scrollHeight: res.windowHeight
        })
      }
    });
    // 系统设置
    app.util.request({
      'url': 'entry/wxapp/system',
      'cachetime': '0',
      success: function (res) {
        // 实例化API核心类
        var qqmapsdk = new QQMapWX({
          key: res.data.map_key
        });
        that.setData({
          mdxx: res.data
        })
        if (res.data.more == '1') {
          that.duoreLoad();
          wx.setNavigationBarTitle({
            title: res.data.pt_name
          })
        }
        if (res.data.more == '2') {
          that.danreLoad();
        }
        wx.setStorageSync('bqxx', res.data)
      },
    })
    // 网址信息
    app.util.request({
      'url': 'entry/wxapp/Url',
      'cachetime': '0',
      success: function (res) {
        // console.log(res.data)
        wx.setStorageSync('imglink', res.data)
        that.setData({
          url: res.data
        })
      },
    })
    // 网址信息
    app.util.request({
      'url': 'entry/wxapp/Url2',
      'cachetime': '0',
      success: function (res) {
        console.log(res.data)
        that.setData({
          url2: res.data
        })
      },
    })
    //home轮播图和开屏公告
    app.util.request({
      'url': 'entry/wxapp/ad2',
      'cachetime': '0',
      success: function (res) {
        console.log("home轮播图和开屏公告")
        var lb = [], kpggimg = [];
        for (var i = 0; i < res.data.length; i++) {
          if (res.data[i].type == '1') {
            lb.push(res.data[i])
          }
          if (res.data[i].type == '2') {
            kpggimg.push(res.data[i])
          }
        }
        console.log(lb, kpggimg)
        that.setData({
          imgUrls: lb,
        })
        if (kpggimg.length != 0) {
          that.setData({
            kpgg: false,
            kpggimg: kpggimg
          })
        }
      },
    })

    //优惠券
    app.util.request({
      'url': 'entry/wxapp/coupons',
      'cachetime': '0',
      success: function (res) {
        console.log("优惠券")
        let idDataSet = that.getIdDataSet(res.data.ok);
        that.classify(res.data.all, idDataSet);

        that.setData({
          coupons: res.data.all,
        })
      },
    })
    //home分类
    app.util.request({
      'url': 'entry/wxapp/storetype',
      'cachetime': '0',
      success: function (res) {
        console.log(res.data)
        var navs = [];
        for (var i = 0, len = res.data.length; i < len; i += 8) {
          navs.push(res.data.slice(i, i + 8));
        }
        console.log(navs)
        that.setData({
          navs: navs,
        })
      },
    })
    wx.getUserInfo({
      success: function (res) {
        console.log(res.userInfo)
        var userInfo = res.userInfo;
        that.setData({
          nickName: userInfo.nickName,
          avatarUrl: userInfo.avatarUrl,
        })
      }, fail: function () {
        wx.showModal({
          title: '警告',
          content: '您点击了拒绝授权,无法正常显示个人信息,点击确定重新获取授权。',
          showCancel: false,
          success: function (res) {
            if (res.confirm) {
              wx.navigateTo({
                url: '../getUserInfo/getUserInfo',
              })
            }
          }
        })
      }, complete: function (res) {
      }
    })
    // 获取用户登录信息
    wx.login({
      success: function (res) {
        var code = res.code
        wx.setStorageSync("code", res.code)
        app.util.request({
          'url': 'entry/wxapp/openid',
          'cachetime': '0',
          data: { code: code },
          success: function (res) {
            console.log(res)
            wx.setStorageSync("key", res.data.session_key)
            // var img = that.data.userInfo.avatarUrl
            // var name = that.data.userInfo.nickName
            // 异步保存用户openid
            wx.setStorageSync("openid", res.data.openid)
            var openid = res.data.openid
            console.log(openid)
            // 获取用户登录信息
            if (openid == '') {
              wx: wx.showToast({
                title: '没有获取到openid',
                icon: '',
                image: '',
                duration: 1000,
                mask: true,
                success: function (res) { },
                fail: function (res) { },
                complete: function (res) { },
              })
            } else {
              app.util.request({
                'url': 'entry/wxapp/Login',
                'cachetime': '0',
                data: { openid: openid, img: that.data.avatarUrl, name: that.data.nickName },
                success: function (res) {
                  console.log(res)
                  // 异步保存用户登录信息
                  wx.setStorageSync('users', res.data)
                  // 获取用户状态
                  app.util.request({
                    'url': 'entry/wxapp/New',
                    'cachetime': '0',
                    data: { user_id: res.data.id, store_id: getApp().sjid },
                    success: function (res) {
                      console.log(res)
                      wx.setStorageSync('new_user', res.data)
                    },
                  })
                },
              })
            }

          },
        })
      }
    })
  },
  //重新排数组的方法
  //领取优惠券  构建ok对象的coupon_id属性集
  getIdDataSet: function (jsonArr) {
    let dataset = new Array();
    let len = jsonArr.length;
    for (let i = 0; i < len; i++) {
      dataset.push(jsonArr[i].coupons_id);
    }
    return dataset;
    console.log(dataset)
  },
  classify: function (origin, comp) {
    console.log("定义优惠券是否领取的函数")
    console.log(origin,comp)
    let received = new Array();
    let unreceive = new Array();
    let len = origin.length;
    for (let i = 0; i < len; i++) {
      if (comp.indexOf(origin[i].id) === -1) {
        unreceive.push(origin[i]);
      } else {
        received.push(origin[i]);
      }
    }
      console.log('从店铺优惠券进入')
      var wlqyhq = [], lqyhq = [];
      for (let i = 0; i < unreceive.length; i++) {
        if (unreceive[i].store_id == getApp().sjid) {
          wlqyhq.push(unreceive[i]);
        }
      }
      this.setData({
        unreceive: wlqyhq
      });
      for (let i = 0; i < received.length; i++) {
        if (received[i].store_id == getApp().sjid) {
          lqyhq.push(received[i]);
        }
      }

      this.setData({
        unreceive: wlqyhq,
        received: lqyhq
      });
    
  },
  ydtj:function(e){
      console.log(e);
      var that = this

      console.log('form发生了submit事件，携带数据为：', e.detail.value)
      var array = this.data.array
      console.log(array)
      if (array.length == 0) {
        wx.showModal({
          title: '提示',
          content: '商家暂未添加桌位类型，暂时不能预定',
        })
        return
      }
      var openid = wx.getStorageSync('openid')
      var store = wx.getStorageSync('store')
      var sjname = store.name
      var uid = wx.getStorageSync('users').id;
      var storeid = store.id;
      var date = e.detail.value.datepicker,zwtype = e.detail.value.zwpicker.name,
        zwid = e.detail.value.zwpicker.id, zdxf = e.detail.value.zwpicker.zd_cost, lxr = e.detail.value.lxr, jcrs = e.detail.value.jcrs, tel = e.detail.value.tel, ydcost = parseFloat(e.detail.value.zwpicker.yd_cost);
        // beizhu = e.detail.value.beizhu;
      console.log(openid, sjname, uid, storeid, date, zwtype, zwid, lxr, jcrs, tel, ydcost)
      that.setData({
        ydcost: ydcost,
        forminfo: e.detail.value
      })
      var warn = "";
      var flag = true;
      if (lxr == "") {
        warn = "请填写您的姓名！";
      } else if (jcrs == '') {
        warn = "请选择您的就餐人数"
      } else if (tel == "") {
        warn = "请填写您的手机号！";
      } else if (!(/^0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8}$/.test(tel))) {
        warn = "手机号格式不正确";
      } else {
        flag = false;
    
          // if (that.data.store.is_yypay == '1') {}
            app.util.request({
              'url': 'entry/wxapp/Reservation',
              'cachetime': '0',
              data: {
                store_id: storeid, user_id: uid, xz_date: date,table_type_id: zwid, table_type_name: zwtype, zd_cost: zdxf, link_name: lxr, link_tel: tel, jc_num: jcrs, money: ydcost, ydcode: ''
              },
              success: function (res) {
                console.log(res)
                if (res.data != '预定失败') {
                  // wx.showModal({
                  //   title: '提示',
                  //   content: '预约成功等待审核',
                  //   showCancel: false,
                  // })
                  var message = '恭喜您已经成功预定了' + date + '的' + zwtype;
                  that.setData({
                    hiddenModal: !that.data.hiddenModal,
                    height:0,
                    message:message
                  })
                  //发邮件
                  if (that.data.ptxx.is_email == '1') {
                    app.util.request({
                      'url': 'entry/wxapp/email',
                      'cachetime': '0',
                      data: { store_id: storeid, type: '预约' },
                      success: function (res) {
                        console.log(res)
                      },
                    })
                  }
                  //发短信 
                  app.util.request({
                    'url': 'entry/wxapp/sms2',
                    'cachetime': '0',
                    data: { store_id: storeid },
                    success: function (res) {
                    },
                  })
                  //发模板消息
                  app.util.request({
                    'url': 'entry/wxapp/Message3',
                    'cachetime': '0',
                    data: {
                      openid: openid, form_id: form_id, xz_date: date, store_name: sjname, yjdd_date: time,
                      link_name: lxr, link_tel: tel, jc_num: jcrs, remark: beizhu
                    },
                    success: function (res) {
                      console.log(res)
                    },
                  })
                }
                else {
                  wx.showToast({
                    title: '请重试',
                    icon: 'loading',
                    duration: 1000,
                  })
                }
              },
            })
          
        
      }
      if (flag == true) {
        wx.showModal({
          title: '提示',
          content: warn
        })
      }
  },
  popwinyuding: function () {
    var chHEIGHT = this.data.height == '580' ? "0" : "580";

    this.setData({
      height: chHEIGHT,

    });
  },
  //排队
  scanning: function () {
    var that = this;
    //检测是否已经排队
    var store_id = that.data.sjid
    var uid = wx.getStorageSync('users').id
    //获取店铺信息
    app.util.request({
      'url': 'entry/wxapp/SearLineUp',
      'cachetime': '0',
      data: {store_id:store_id,uid:uid},
      success: function (res) {
        console.log(res);
        if (res.data.code == 200) {
          console.log(res.data.data);
          console.log('--------------------------------------')
          that.setData({
            pd: res.data.data,
            hidescanningOK: !that.data.hidescanningOK,
            
          })
        }else{
          that.setData({
            hide: !that.data.hide
            // hidescanningOK: !that.data.hidescanningOK,
          })
        }
      }
    })
    // this.setData({
    //   hide: !this.data.hide
    //   // hidescanningOK: !that.data.hidescanningOK,
    // })
  },
  //取号
  scanningOK: function (e) {
    this.setData({
      // hidescanningOK: !this.data.hidescanningOK,
      hide:true
    })
    // console.log(e);
  },
  formsubmit:function(e){
    var that = this;
    var arr = e.detail.value
    arr.store_id = that.data.sjid
    arr.uid = wx.getStorageSync('users').id
   
    if(!arr.ren_num){
      wx.showToast({
        title: '请填写人数',
      })
      return false;
    }

    if (!arr.phone) {
      wx.showToast({
        title: '请填写手机号',
      })
      return false;
    }

    //获取店铺信息
    app.util.request({
      'url': 'entry/wxapp/LineUp',
      'cachetime': '0',
      data: arr,
      success: function (res) {
          if(res.data.code == 200){
            that.setData({
              pd:res.data.data,
              hidescanningOK: !that.data.hidescanningOK,
              hide: true
            })
          }
      }
    })
  },
  scanningOKclose: function () {
    console.log("-----------------排队成功关闭按钮点击了----------------")
    this.setData({
      hidescanningOK: true
    })
  },
  scanningclose: function () {
    console.log("-----------------关闭按钮点击了----------------")
    this.setData({
      hide: true
    })
  },
  //外卖跳转
  takeOutFood:function(){
    wx.navigateTo({
      url: '../foodList/foodList?type=' + 2
    })
  },
  danreLoad: function () {
    this.setData({
      hdnum: 0,
    })
    var that = this
    var time = util.formatTime(new Date());
    // 再通过setData更改Page()里面的data，动态更新页面的数据  
    var settime = time.slice(11, 16)
    // 商家信息
    console.log("商家信息")
    console.log(that.data.mdxx.default_store)
    console.log(wx.getStorageSync('users').id)
    app.util.request({
      'url': 'entry/wxapp/isyuyue',
      'cachetime': '0',
      data: { user_id: wx.getStorageSync('users').id ,store_id:that.data.mdxx.default_store},
      success: function (res) {
        console.log(res);
        console.log('----------------------------------预约--------------------------------')
        if(res.data.code == 200){
          var message = '恭喜您已经成功预定了' + res.data.data.xz_date + '的' + res.data.data.table_type_name;
          //有预约
          that.setData({
             isyuyue:true,
              yuyue:res.data.data,
              message:message
          })
        }else{
          //没有预约
          that.setData({
            isyuyue: false,
          })
        }
      },
    })

    var current_time = that.data.current_time
    app.util.request({
      'url': 'entry/wxapp/Store',
      'cachetime': '0',
      data: { id: that.data.mdxx.default_store, user_id: wx.getStorageSync('users').id },
      success: function (res) {
        console.log('店铺信息')
        wx.setStorageSync("store",res.data);
        //查询商品列表
        app.getFoodList(res.data.id);
        //背景音乐
        if (res.data.store_mp3 != '' && res.data.is_mp3 == '1') {
          wx.playBackgroundAudio({
            dataUrl: res.data.store_mp3,
          })
          wx.getBackgroundAudioPlayerState({
            success: function (res) {
              console.log(res)
              var status = res.status
              var dataUrl = res.dataUrl
              var currentPosition = res.currentPosition
              var duration = res.duration
              var downloadPercent = res.downloadPercent
            },
            fail: function (res) {
              console.log(res)
            },
            complete: function (res) {
              console.log(res)
            }
          })
        }
        //背景色
        wx.setStorageSync('nbcolor', res.data.color)
        getApp().sjid = res.data.id
        wx.setNavigationBarTitle({
          title: res.data.name
        })
        wx.setNavigationBarColor({
          frontColor: '#000000',
          backgroundColor: "#ffffff",
        })
        that.setData({
          color: res.data.color,
          sjid:res.data.id
        })
        app.util.request({
          'url': 'entry/wxapp/TableType',
          'cachetime': '0',
          data: { store_id: that.data.sjid },
          success: function (res) {
            that.setData({
              array: res.data
            })
          },
        })
        //获取店铺信息
        app.util.request({
          'url': 'entry/wxapp/Reduction',
          'cachetime': '0',
          data: { id: getApp().sjid },
          success: function (res1) {
            console.log("获取店铺信息");
            console.log(res1);
            that.setData({
              mj: res1.data
            })
            if (res1.data.length != 0 && res.data.xyh_open == '1') {
              that.setData({
                hdnum: 2
              })
            }
            else if ((res1.data.length != 0 && res.data.xyh_open != '1') || (res1.data.length == 0 && res.data.xyh_open == '1')) {
              that.setData({
                hdnum: 1
              })
            }
            else {
              that.setData({
                hdnum: 0
              })
            }
          }
        })
        var shop_time = res.data.time
        var close_time = res.data.time2
        var shop_time1 = res.data.time3
        var close_time1 = res.data.time4
        var rest = res.data.is_rest
        console.log('当前的系统时间为' + current_time)
        console.log('商家的营业时间从' + shop_time + '至' + close_time, shop_time1 + '至' + close_time1)
        that.setData({
          rest: res.data.is_rest
        })
        if (rest == 1) {
          console.log('商家正在休息')

        } else {
          console.log('商家没有休息')
          if (close_time1 > shop_time) {
            if (current_time > shop_time && current_time < close_time || current_time > shop_time1 && current_time < close_time1) {
              console.log('商家正常营业')
              that.setData({
                time: 1
              })
            }
            else if (current_time < shop_time || current_time > close_time && current_time < shop_time1) {
              console.log('商家还没开店呐，稍等一会儿可以吗？')
              that.setData({
                time: 2
              })
            }
            else if (current_time > close_time1) {
              console.log('商家以及关店啦，明天再来吧')
              that.setData({
                time: 3
              })
            }
          }
          else if (close_time1 < shop_time) {
            if (current_time > shop_time && current_time < close_time || current_time > shop_time1 && current_time > close_time1 || current_time < shop_time1 && current_time < close_time1) {
              console.log('商家正常营业')
              that.setData({
                time: 1
              })
            }
            else if (current_time < shop_time || current_time > close_time && current_time < shop_time1) {
              console.log('商家还没开店呐，稍等一会儿可以吗？')
              that.setData({
                time: 2
              })
            }
            else if (current_time > close_time1) {
              console.log('商家以及关店啦，明天再来吧')
              that.setData({
                time: 3
              })
            }
          }
        }

        var distance = Number(res.data.distance)
        that.setData({
          store: res.data,
          distance: distance
        })
        app.util.request({
          'url': 'entry/wxapp/zhuanh',
          'cachetime': '0',
          data: { op: res.data.coordinates },
          success: function (res) {
            console.log(res)
            console.log(res.data.locations[0].lat + ',' + res.data.locations[0].lng)
            that.setData({
              sjdzlat: res.data.locations[0].lat,
              sjdzlng: res.data.locations[0].lng
            })
          }
        })
      },
    })
  },
  //展示推荐商品
  setShowFoodList:function(){
    var that = this;
    console.log("展示推荐商品")
    let tuijian = this.data.foodList[0].goods,
        tuijian2 = [];
    tuijian.forEach((val, index)=>{
      if(index<=1){
        console.log(val.details);
        var res = wxParse.wxParse('detail', 'html', val.details, that, 0);
        console.log(res);
        console.log('1232131312321312321312312312321321312312')
        tuijian2.push(val);
      }
    })

    // return false;
    this.setData({"tuijian":tuijian2})
  },
  bindDateChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      date: e.detail.value
    })
  },
  bindTimeChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      time: e.detail.value
    })
  },
  //  五星好评 
  pingfens: function (pingfen) {
    // pingfen = 4.2;
    var xs = String(pingfen)
    var xss = xs.split(".");
    var xiao = parseFloat("0." + xss[1])

    var nums = [];
    if ((pingfen / 0.5) % 2 == 0) {
      for (var i = 0; i < 5; i++) {
        if (i < pingfen) {
          nums.push(this.data.ling);
        } else {
          nums.push(this.data.zheng);
        }
      }
    } else {//评分不为整数，如3.5、2.5
      for (var i = 0; i < 5; i++) {
        if (i < pingfen - xiao) {
          nums.push(this.data.ling);//先把整数分离出来，如：3.5，这里就是先把3分离出来，把代表1的图片放进去
        } else if (i == (pingfen - xiao)) {
          nums.push(this.data.ban);//把小数的部分分离出来，如：3.5里的0.5，把代表0.5的图片放进去
        } else {
          nums.push(this.data.zheng);//然后剩下的就是没有满的用代表0的图片放进去，如：3.5，里面放进去了3个代表1的图片，然后放入了1个代表0.5的图片，最后还剩一个图片的位置，这时候就放代表0的图片
        }
      }
    }
    return nums;
  },
  //  五星好评 END

  
  onChangeShowState: function () { 
    var that = this;
    that.setData({
      showView: (!that.data.showView)
    })
  },


  reserve: function () {
    var chHEIGHT = this.data.height == '580' ? "0" : "580";

    this.setData({
      height: chHEIGHT,

    });
  },
  popwinyuding01: function () {
    var chHEIGHT01 = this.data.height == '580' ? "0" : "580";
    var chHEIGHT02 = this.data.height == '0' ? "300" : "0";
    this.setData({
      height01: chHEIGHT01,
      height002: chHEIGHT02,

    });
  },
 




  // 弹框
  listenerButton: function (e) {
  

    this.setData({
      hiddenModal: !this.data.hiddenModal
    })
  },

  listenerConfirm: function () {
    this.setData({
      hiddenModal: true
    })
  },

  listenerCancel: function () {
    this.setData({
      hiddenModal: true
    })
  },
  onShareAppMessage:function(){
    return {
      title: '神炖焗',
      path: '/zh_dianc/pages/home/home'
    }
  }
})